let decode_one = function
  | ".-"     -> "a"
  | "-..."   -> "b"
  | "-.-."   -> "c"
  | "-.."    -> "d"
  | "."      -> "e"
  | "..-."   -> "f"
  | "--."    -> "g"
  | "...."   -> "h"
  | ".."     -> "i"
  | ".---"   -> "j"
  | "-.-"    -> "k"
  | ".-.."   -> "l"
  | "--"     -> "m"
  | "-."     -> "n"
  | "---"    -> "o"
  | ".--."   -> "p"
  | "--.-"   -> "q"
  | ".-."    -> "r"
  | "..."    -> "s"
  | "-"      -> "t"
  | "..-"    -> "u"
  | "...-"   -> "v"
  | ".--"    -> "w"
  | "-..-"   -> "x"
  | "-.--"   -> "y"
  | "--.."   -> "z"
  | ".----"  -> "1"
  | "..---"  -> "2"
  | "...--"  -> "3"
  | "....-"  -> "4"
  | "....."  -> "5"
  | "-...."  -> "6"
  | "--..."  -> "7"
  | "---.."  -> "8"
  | "----."  -> "9"
  | "-----"  -> "0"
  | code -> failwith ("Unrecognized morse code: " ^ code)

let decode s =
  let chars = List.map decode_one s in
  String.concat "" chars
